'are from WIN32API.txt coming with VB 5.0 Proffessional
'But, the callback function created by myself,
'after wasting hours on the documents related with
'C++ Windows midi programming.
'The program is not running from VB
'on my computer. So I had to make a shortcut
'to it's EXE, and everytime compiled it to the
'same exe file and run it from desktop.
'I don't know why, but I advise you to do the same.
'Function declarations for midi out
Declare Function midiOutGetNumDevs Lib "winmm" () As Long
Declare Function midiOutGetDevCaps Lib "winmm.dll" Alias "midiOutGetDevCapsA" (ByVal uDeviceID As Long, lpCaps As MIDIOUTCAPS, ByVal uSize As Long) As Long
Declare Function midiOutOpen Lib "winmm.dll" (lphMidiOut As Long, ByVal uDeviceID As Long, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal dwFlags As Long) As Long
Declare Function midiOutClose Lib "winmm.dll" (ByVal hMidiOut As Long) As Long
Declare Function midiOutShortMsg Lib "winmm.dll" (ByVal hMidiOut As Long, ByVal dwMsg As Long) As Long
Declare Function midiOutReset Lib "winmm.dll" (ByVal hMidiOut As Long) As Long
'Function declarations for midi in
Declare Function midiInGetNumDevs Lib "winmm.dll" () As Long
Declare Function midiInGetDevCaps Lib "winmm.dll" Alias "midiInGetDevCapsA" (ByVal uDeviceID As Long, lpCaps As MIDIINCAPS, ByVal uSize As Long) As Long
Declare Function midiInOpen Lib "winmm.dll" (lphMidiIn As Long, ByVal uDeviceID As Long, ByVal dwCallback As Any, ByVal dwInstance As Long, ByVal dwFlags As Long) As Long
Declare Function midiInClose Lib "winmm.dll" (ByVal hMidiIn As Long) As Long
Declare Function midiInStart Lib "winmm.dll" (ByVal hMidiIn As Long) As Long
Declare Function midiInStop Lib "winmm.dll" (ByVal hMidiIn As Long) As Long
Declare Function midiInReset Lib "winmm.dll" (ByVal hMidiIn As Long) As Long
Public Const MAXPNAMELEN = 32 ' max product name length (including NULL)
'Type declaration for getting the device capabilities.
'Use with midiInGetDevCaps, midiOutGetdevCaps
Type MIDIINCAPS
wMid As Integer
wPid As Integer
vDriverVersion As Long
szPname As String * MAXPNAMELEN
End Type
Type MIDIOUTCAPS
wMid As Integer
wPid As Integer
vDriverVersion As Long
szPname As String * MAXPNAMELEN
wTechnology As Integer
wVoices As Integer
wNotes As Integer
wChannelMask As Integer
dwSupport As Long
End Type
Public oxMIC As MIDIINCAPS
Public oxMOC As MIDIOUTCAPS
Public tmp As Long, tmp1 As Long, tmp2 As Long
'These are the return values for the second argument
'of our callback function.
Public Const MM_MIM_OPEN = &H3C1 ' Midi in device opened by MidiInOpen
Public Const MM_MIM_CLOSE = &H3C2 ' Midi in device closed by MidiInOpen
Public Const MM_MIM_DATA = &H3C3 ' A non sys-ex midi msg (Note on, note off, pitch ch., bank ch. volume ch. etc..)
Public Const MM_MIM_LONGDATA = &H3C4 'Sys-ex data
Public Const MM_MIM_ERROR = &H3C5 'An error occured inputting non sys-ex data
Public Const MM_MIM_LONGERROR = &H3C6 'An error occured inputting sys-ex data
Public Const MIDIERR_BASE = 64
'These are the callback types.
'We are using the CALLBACK_FUNCTION constant
'Windows calls our callback function each time
'the opened midi in port inputs data
Public Const CALLBACK_TYPEMASK = &H70000 ' callback type mask
Public Const CALLBACK_NULL = &H0 ' no callback
Public Const CALLBACK_WINDOW = &H10000 ' dwCallback is a HWND
Public Const CALLBACK_TASK = &H20000 ' dwCallback is a HTASK
Public Const CALLBACK_FUNCTION = &H30000 ' dwCallback is a FARPROC
' Check these, if a function has returned an error:
' General error return values
Public Const MMSYSERR_BASE = 0
Public Const MMSYSERR_NOERROR = 0 ' no error
Public Const MMSYSERR_ERROR = (MMSYSERR_BASE + 1) ' unspecified error
Public Const MMSYSERR_BADDEVICEID = (MMSYSERR_BASE + 2) ' device ID out of range